<html lang="en">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .myborder {
            border: 1px blueviolet solid;
        }
    </style>
</head>

<body>
    <div id="div1" style="color: red;" class="myborder" title="div1">
        这是div1
    </div>
    <script>
        // js操作属性一
        let div1 = document.getElementById("div1")
        div1.title = "XXXXX"
        div1.style.color = "pink"
        div1.style.backgroundColor = "brown"

        //js操作属性二
        div1.setAttribute("title", "YYYY")
        let title = div1.getAttribute("title")
    </script>
</body>

</html>